package com.ruoyi.framework.field;


import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.ReUtil;
import com.ruoyi.common.utils.StringUtils;

/**
 * 校验工具
 */
public class FieldCheckUtils {

    public static boolean isIdCard(String card) {
        return IdcardUtil.isValidCard(card);
    }

    public static boolean isPhone(String phone) {
        return PhoneUtil.isMobile(phone);
    }

    public static boolean pattern(String pattern, String text) {
        return ReUtil.isMatch(pattern, text);
    }

    public static boolean isMaxLength(String text, Long maxLength) {
        return text.length() <= maxLength;
    }

    public static boolean isMinLength(String text, Long minLength) {
        return text.length() >= minLength;
    }

    public static boolean isMax(Long number, Long max) {
        return number <= max;
    }

    public static boolean isMin(Long number, Long min) {
        return number >= min;
    }

    public static boolean isNotNull(Object obj) {
        if (obj instanceof String) {
            return StringUtils.isNotBlank(obj.toString());
        }
        return null != obj;
    }


}
